package Fibonacci;

import java.util.Arrays;

public class Fibonacci {
   public static int fibonacci(int i){
       int[] cache = new int[i+1];
       Arrays.fill(cache,-1);
       cache[0] = 0;
       cache[1] = 1;
       return f(i,cache);
   }
   public static int f(int i , int[] cache){
       if(cache[i] != -1){
           return cache[i];
       }
       cache [i] = f(i-1,cache) + f(i-2,cache);
      return cache[i];
   }
}